<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class RegistPostRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'user_name' => 'bail|required|alpha_num|max:30|unique:user',
            'email' => 'required|email|max:30|unique:user',
            'password' => 'required|min:6|confirmed',
        ];
    }

    /**
     * @Author   tianyu
     * @DateTime 2017-04-06T18:00:17+0800
     * @return   array
     */
    public function messages()
    {
        return [
            'user_name.required' => '用户名不能为空',
            'user_name.alpha_num' => '用户名必须是字母或数字',
            'user_name.max' => '用户名长度不能超过30字符',
            'user_name.unique' => '该用户名已存在',
            'email.required' => '邮箱不能为空',
            'email.email' => '邮箱格式不正确',
            'email.max' => '邮箱长度不能超过30字符',
            'email.unique' => '该邮箱已存在',
            'password.required' => '密码不能为空',
            'password.min' => '密码长度不能小于6字符',
            'password.confirmed' => '两次密码不一致',
        ];
    }
}
